<?php

define('HOST', '127.0.0.1:3306');
define('USERNAME', 'czdatabase');
define('PASSWORD', 'aWuPaQPnfPq2jVJm');

DBparse("show tables");

function DBparse($sql)
{
	mysql_connect(HOST, USERNAME, PASSWORD);
	mysql_select_db('czdatabase');
	if(is_select($sql))
	{
		$query = mysql_query($sql);
		while($r = mysql_fetch_assoc($query))
		{
			//print_r($r);
			$table = $r['Tables_in_czdatabase'];

			echo $table . "<br>";
			//$sql_0 = "drop table $table";
			//mysql_query($sql_0);
		}
	}
	else
	{
		mysql_query($sql);
	}
}

function get_first_word($str)
{
	$str = trim($str);
	$str_arr = explode(' ', $str);

	return $str_arr[0];
}

function is_select($sql)
{
	$word = get_first_word($sql);
	if(in_array($word, array('show', 'select')))
	{
		return true;
	}
}
?>